#!/usr/bin/python

import sys
sys.path.append('../scripts')

import unittest
from xml.dom import minidom

import game

class TestGame(unittest.TestCase):
	def setUp(self):
		game.world = game.World()
		last_time = None
		command = None

	def testTick(self):
		input = """<?xml version="1.0" encoding="utf-8"?>
		<end>
			<input>
				<j/>
			</input>
		</end>"""
		player = game.Entity("player") 
		game.world.append(player)
		game._on_tick(input, 0.2)

		self.assertEquals(player, game.world[0])
		self.assertEquals(0.8, game.world[0].pos[0])

		input = """<?xml version="1.0" encoding="utf-8"?>
		<end>
			<input>
			</input>
		</end>"""
		game._on_tick(input, 1)

		self.assertEquals(player, game.world[0])

if __name__ == '__main__':
	unittest.main()
